<template>
  <el-dialog v-dialogDrag
             :title="'详情 ['+this.dataForm.id + ']'"
             :close-on-click-modal="true"
             :visible.sync="visible">
    <div style="height: 600px;overflow-y: scroll; padding-right: 10px;">

      <el-form :inline="true" :model="searchForm" @keyup.enter.native="queryList()">

        <el-form-item>
          <el-input v-model="searchForm.taskExecLogId" placeholder="任务执行日志ID" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.jobExecLogId" placeholder="作业执行日志ID" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.azCode" placeholder="地域编号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.execDate" placeholder="执行日期" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.appMode" placeholder="应用模式" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.appJarName" placeholder="应用名称" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.appRunMode" placeholder="运行模式" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.execStartupCmd" placeholder="执行启动命令" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.execStatus" placeholder="执行状态" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.execErrorNum" placeholder="异常错误累计次数" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.agentIpv4" placeholder="代理实例IP" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.startupTime" placeholder="启动时间" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="searchForm.resourceScore" placeholder="运行占用资源分值" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="queryList(1)">查询</el-button>
          <el-button type="" @click="addEntity()">新增</el-button>
          <el-button type="danger" @click="deleteEntity()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
        </el-form-item>
      </el-form>

      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        @selection-change="selectionChangeHandle"
        style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>

        <el-table-column prop="id"  label="主键" header-align="center" align="center"></el-table-column>
        <el-table-column prop="taskExecLogId"  label="任务执行日志ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="jobExecLogId"  label="作业执行日志ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="taskTriggerTime"  label="任务触发时间戳" header-align="center" align="center"></el-table-column>
        <el-table-column prop="execDate"  label="执行日期" header-align="center" align="center"></el-table-column>
        <el-table-column prop="appMode"  label="应用模式" header-align="center" align="center"></el-table-column>
        <el-table-column prop="appJarName"  label="应用名称" header-align="center" align="center"></el-table-column>
        <el-table-column prop="appRunMode"  label="运行模式" header-align="center" align="center"></el-table-column>
        <el-table-column prop="execStartupCmd"  label="执行启动命令" header-align="center" align="center"></el-table-column>
        <el-table-column prop="execStatus"  label="执行状态" header-align="center" align="center"></el-table-column>
        <el-table-column prop="execResult"  label="执行结果" header-align="center" align="center"></el-table-column>
        <el-table-column prop="execErrorNum"  label="异常错误累计次数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="agentIpv4"  label="代理实例IP" header-align="center" align="center"></el-table-column>
        <el-table-column prop="startupTime"  label="启动时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="endTime"  label="结束时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createTime"  label="创建时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updateTime"  label="更新时间戳" header-align="center" align="center"></el-table-column>

        <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="modEntity(scope.row)">修改</el-button>
            <el-button type="text" size="small" @click="showDetail(scope.row)">详细</el-button>
            <el-button type="text" size="small" @click="deleteEntity(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>


    </div>

    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        rowData: {},
        visible: false,
        searchForm: {
        },
        dataList: [],
      }
    },
    methods: {
      init(id, data) {
        this.dataForm.id = id || ''
        this.visible = true
        // this.rowData = data
        // this.$nextTick(() => {
        //   this.$refs['dataForm'].resetFields();
        //   if (this.dataForm.id) {
        //     this.dataForm = data;
        //   }
        // })
      },
      queryList(clr) {
        if (typeof (clr) != 'undefined') {
          this.page = 1
        }
        this.dataListLoading = true
        let obj = {
          'page': this.page,
          'size': this.pageSize,
          //isTrans: true,
          //transParams: ['FlowType', 'ApplyResult', 'ReceiveStatus'],
          //transDict: ['flowType', 'applyResult', 'receiveStatus']
        }
        obj = Object.assign(obj, this.searchForm)
        this.getTableList('/api/agentExec1LogList', obj, (data) => {
          this.dataListLoading = false
          if (data.code == '000000' && data.rows && data.rows.length > 0) {
            this.dataList = data.rows
            this.totalPage = data.total
          } else {
            this.dataList = []
            this.totalPage = 0
          }
        })
      },

    }
  }
</script>
